package com.hncc.kumao.dao.impl;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.hncc.kumao.dao.IUserDao;
import com.hncc.kumao.entity.User;
import com.hncc.kumao.util.MD5Utils;
/**
 * 数据访问类
 * @author Administrator
 *
 */
public class UserDao extends BaseDao<User> implements IUserDao {

	
	/**
	 * 构建查询条件
	 * @param dep1
	 * @param dep2
	 * @param param
	 * @return
	 */
	public DetachedCriteria getDetachedCriteria(User user1,User user2,Object param){
		DetachedCriteria dc=DetachedCriteria.forClass(User.class);
		if(user1!=null){
		    if(user1.getPhone() != null && user1.getPhone().trim().length() > 0) {
		        dc.add(Restrictions.eq("phone", user1.getPhone()));		        
		    }
		    if(user1.getEmail() != null && user1.getEmail().trim().length() > 0) {
		        dc.add(Restrictions.eq("email", user1.getEmail()));
		    }
		    if(user1.getUsername() != null && user1.getUsername().trim().length() > 0) {
		        dc.add(Restrictions.eq("username", user1.getUsername()));
		    }
		    if(user1.getPassword() != null && user1.getPassword().trim().length() > 0) {
                dc.add(Restrictions.eq("password", user1.getPassword()));
            }
		}
		return dc;
	}
}

